package cc.vv.btpartyjob.partymanager.delegate

import android.support.v4.view.ViewPager
import android.view.View
import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.adapter.ManagerViewPageAdapter
import cc.vv.mvp.delegate.BaseAppDelegate

/**
 * 第一书记
 * Created by Chen.qi on 2018/10/24.
 */
class DiYiShuJiActivityDelegate : BaseAppDelegate() {

    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_diyishuji
    }


    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_dysJ_topBar)
        titleBar?.setTitle(topBarTitle)
    }


    fun setRightIcon(show: Boolean) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_dysJ_topBar)
        if (show) {
            titleBar?.rl_ljtb_right_layout?.visibility = View.VISIBLE
        } else {
            titleBar?.rl_ljtb_right_layout?.visibility = View.GONE
        }
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_dysJ_topBar)
        titleBar?.setEventInterface(event)
    }

    /**
     * 设置社会组织和动态组织显示与否
     */
    fun setSocialSelected(socialSelected: Boolean) {
        val socialText = getView<TextView>(R.id.tv_dysJ_jobQiaDao)
        val socialDynamicText = getView<TextView>(R.id.tv_dysJ_jobQingKuang)
        socialText?.isSelected = socialSelected
        socialDynamicText?.isSelected = !socialSelected
    }

    /**
     * 设置adatper
     */
    fun setAdapterData(adapter: ManagerViewPageAdapter) {
        getView<ViewPager>(R.id.vp_dysJ_viewPager)?.adapter = adapter
    }

    /**
     * 设置viewpager位置
     */
    fun setViewPagerPos(currentPos: Int) {
        getView<ViewPager>(R.id.vp_dysJ_viewPager)?.currentItem = currentPos
    }

    fun bindViewPagerListener(listener: ViewPager.OnPageChangeListener) {
        val pager = getView<ViewPager>(R.id.vp_dysJ_viewPager)
        pager?.addOnPageChangeListener(listener)
    }

}